import { http } from "@/utils/http";

/** 操作日志模型定义 */
export type OperLogModel = {
  operId: number;
  title: string;
  businessType: number;
  method: string;
  requestMethod: string;
  operatorType: number;
  operName: string;
  deptId: number;
  operUrl: string;
  operIp: string;
  operLocation: string;
  operParam: string;
  errorMsg: string;
  operTime: string;
};

/** 分页获取操作日志列表 */
export const getOplogListApi = (data: IReqPagerData) => {
  return http.request<Resp<IRespPagerData<OperLogModel>>>(
    "get",
    "/oplog/page-list",
    { params: data }
  );
};

/** 获取操作日志详情 */
export const getOplogByIdApi = (operId: number) => {
  return http.request<Resp<{
    info: OperLogModel
  }>>('get', '/oplog/getOne', {
    params: { operId }
  });
};

/** 新增操作日志 */
export const addOplogApi = (data: Partial<OperLogModel>) => {
  return http.request<Resp<null>>("post", "/oplog", { data });
};

/** 删除操作日志 */
export const deleteOplogApi = (operId: number) => {
  return http.request<Resp<null>>("delete", `/oplog/${operId}`);
};

/** 批量删除操作日志 */
export const batchDeleteOplogApi = (operIds: number[]) => {
  return http.request<Resp<null>>("delete", "/oplog/batch-del", {
    data: { operIds }
  });
};